<?php

namespace Amis\feedback;

use Amis\Basics\AmisBasics;

class Dialog extends AmisBasics
{
    public string $type       = 'button';

    public function title(string $title)
    {
        $this->title = $title;
        return $this;
    }

    public function actionType(string $type = 'dialog')
    {
        $this->actionType = $type;
        return $this;
    }

    public function body(...$body)
    {
        $this->set('body', ...$body);
        return $this;
    }

    public function size(string $size = '')
    {
        if (in_array($size, ['xs', 'sm', 'md', 'lg'])) {
            $this->size = $size;
        }
        return $this;
    }

    public function bodyClassName(string $bodyClassName = 'modal-body')
    {
        $this->bodyClassName = $bodyClassName;
        return $this;
    }

    public function closeOnEsc(bool $closeOnEsc = false)
    {
        $this->closeOnEsc = $closeOnEsc;
        return $this;
    }

    public function showCloseButton(bool $showCloseButton = true)
    {
        $this->showCloseButton = $showCloseButton;
        return $this;
    }

    public function showErrorMsg(bool $showErrorMsg = true)
    {
        $this->showErrorMsg = $showErrorMsg;
        return $this;
    }

    public function showLoading(bool $showLoading = true)
    {
        $this->showLoading = $showLoading;
        return $this;
    }

    public function disabled(bool $disabled = true)
    {
        $this->disabled = $disabled;
        return $this;
    }

    public function actions(array $actions = [])
    {
        $this->actions = $actions;
        return $this;
    }

    public function data($data)
    {
        $this->data = $data;
        return $this;
    }
}
